package com.jifeng.sterilizer.controller;

import java.util.Arrays;
import java.util.Map;

import com.jifeng.sterilizer.utils.PageUtils;
import com.jifeng.sterilizer.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.jifeng.sterilizer.entity.UserMenuEntity;
import com.jifeng.sterilizer.service.UserMenuService;



/**
 * 
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-08-31 11:53:24
 */
@RestController
@RequestMapping("sterilizer/usermenu")
public class UserMenuController {
    @Autowired
    private UserMenuService userMenuService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userMenuService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		UserMenuEntity userMenu = userMenuService.getById(id);

        return R.ok().put("userMenu", userMenu);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserMenuEntity userMenu){
		userMenuService.save(userMenu);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody UserMenuEntity userMenu){
		userMenuService.updateById(userMenu);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		userMenuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
